package com.org.redis.config;

public class RedisConfig {

    public static String HOST = "127.0.0.1";
    public static int PORT = 6379;
    public static int DATABASE = 0;
    public static String READ_HOST = "127.0.0.1";
    public static int READ_PORT = 6379;
    public static int READ_DATABASE = 0;
    public static int MAX_TOTAL = 50;
    public static int MAX_ACTIVE = 50;
    public static int MAX_IDLE = 10;
    public static long MAX_WAIT = 10000;
    public static int TIMEOUT = 10000;
    public static boolean TEST_ON_BORROW = true;
    public static boolean TEST_ON_RETURN = true;

    public static final String REDIS_CLASS = "com.org.redis.config.Redis";
    public static final String PROPERTIES_NAME = "application.properties";
    public static final String REDIS_PROPERTIES_NAME = "redis.properties";

    public static void setConfig(Redis redis) {
        if (redis.getHost() != null && redis.getHost().length() > 0) {
            RedisConfig.HOST = redis.getHost();
        }
        if (redis.getPort() > 0) {
            RedisConfig.PORT = redis.getPort();
        }
        if (redis.getDatabase() > 0) {
            RedisConfig.DATABASE = redis.getDatabase();
        }
        if (redis.getReadHost() != null && redis.getReadHost().length() > 0) {
            RedisConfig.READ_HOST = redis.getReadHost();
        }
        if (redis.getReadPort() > 0) {
            RedisConfig.READ_PORT = redis.getPort();
        }
        if (redis.getReadDatabase() > 0) {
            RedisConfig.READ_DATABASE = redis.getDatabase();
        }
    }

}
